package com.evil.kingdom.controller.world.city;

import com.evil.common.core.entity.R;
import com.evil.kingdom.pojo.entity.world.city.City;
import com.evil.kingdom.pojo.entity.world.city.CityGeneral;
import com.evil.kingdom.service.world.city.CityGeneralService;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 城池武将
 *
 * @author liyang
 * @date 2024-05-22 17:11
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/city/general")
public class CityGeneralController {

    private final CityGeneralService cityGeneralService;

    /**
     * 新增城池武将
     *
     * @param cityGeneral cityGeneral
     * @return R
     */
    @PostMapping("/add")
    public R<CityGeneral> add(@RequestBody @Validated CityGeneral cityGeneral) {
        return R.success(cityGeneralService.add(cityGeneral));
    }

    /**
     * 新增城池武将
     *
     * @param name name
     * @return R
     */
    @PostMapping("/del")
    public R<CityGeneral> del(String name) {
        cityGeneralService.del(name);
        return R.success();
    }

    /**
     * 查询武将位置
     *
     * @param name name
     * @return R
     */
    @RequestMapping("/where")
    public R<City> where(@RequestParam(name = "name")String name) {
        return R.success(cityGeneralService.where(name));
    }
}
